//
// Created by liushuai on 2021/2/17.
//

#include "countSegments.h"
<<<<<<< HEAD:cxx/algorithm/src/countSegments.cc
int countSegments(string s){
    int res = 0;
    int start = 0;
    int end = 0;
    int size = s.size();
    if(size==0)
        return 0;
    while (start<size&&end<size){
        if(s[start]!=' '&&s[end]!=' '){
            while (s[end]!=' '&&end<size)
                end++;
            res+=1;
            start = end+1;
            end = start;
        } else{
            start++;
            end++;
        }
    }
    return res;
=======
int countSegments(string s) {
  int res = 0;
  int start = 0;
  int end = 0;
  int size = s.size();
  if (size == 0) return 0;
  while (start < size && end < size) {
    if (s[start] != ' ' && s[end] != ' ') {
      while (s[end] != ' ' && end < size) end++;
      res += 1;
      start = end + 1;
      end = start;
    } else {
      start++;
      end++;
    }
  }
  return res;
>>>>>>> dev:cxx/algorithm/common/src/countSegments.cc
}